<%@page language="java" contentType="text/html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.*" %>
<%@ page import="Personal.Person" %>
<%@ page import="Personal.Doctor" %>
<%@ page import="Personal.Patient" %>
<%@ taglib uri="/WEB-INF/hospital.tld" prefix="hosp"%>
<fmt:setBundle basename="hospital"/>
<html>
<head>
<title>Doctors tasks</title>
</style>

</head>

<jsp:useBean id="displayedUser" scope="request" class="Doctor"/>
<h2><fmt:message key="doctor"/>. <fmt:message key="name"/> : ${displayedUser.name}</h2>
<h2 align = "center"> <fmt:message key="intakes"/> </h2>
<table border="1">
   <tr width="100%">
        <td width= "50%"><fmt:message key="date"/></td>
        <td width = "20%"><fmt:message key="patient"/></td>
        <td width= "50%"><fmt:message key="comment"/></td>
   </tr>
<c:forEach var="intake" items="${displayedUser.intakes}">
   <tr>
       <td> <fmt:formatDate type="date" value="${intake.date}"/> </td>
       <td> <a href="/show.do?id=${intake.patient.idPerson}">${intake.patient.name}</a> </td>
       <td>  ${intake.comment}  </td>
       <td>
           <hosp:hasRights user = "${displayedUser}">
                <a href = "/addIntake.jsp?idIntake=${intake.id}"><fmt:message key="edit"/></a>
                <a href = "/delIntake.do?idIntake=${intake.id}"><fmt:message key="remove"/></a>
            </hosp:hasRights>
       </td>
   </tr>
</c:forEach>
</table>
<hosp:hasRights user = "${displayedUser}">
    <a href = "/addIntake.jsp"><fmt:message key="addIntake"/></a>
</hosp:hasRights>
<br>

<fieldset>
<h2 align = "center"><fmt:message key="operations"/></h2>
<table class="pp"  border="1">
   <tr width="100%">
        <td class="vertical-align: center" width= "50%"><fmt:message key="date"/></td>
        <td width= "20%"><fmt:message key="Cabinet"/></td>
        <td width= "70%"><fmt:message key="OperationName"/></td>
        <td width= "20%"><fmt:message key="patient"/></td>
        <td width= "50%"><fmt:message key="doctor"/></td>
   </tr>
<c:forEach var="operation" items="${displayedUser.operations}">
   <tr style="vertical-align: center">
       <td style="vertical-align: center">  <fmt:formatDate type="date" value="${operation.date}"/>  </td>
       <td>  ${operation.cabinetNumber}  </td>
       <td>  ${operation.name}  </td>
       <td> <a href="/show.do?id=${operation.prescription.patient.idPerson}">${operation.prescription.patient}</a> </td>

       <td>
            <ul>
            <c:forEach var="doctor" items="${operation.doctors}">
                <li>
                    <a href="/show.do?id=${doctor.idPerson}">${doctor.name}</a>
                </li>
            </c:forEach>
            </ul>
       </td>

   </tr>

</c:forEach>
</table>
</fieldset>

</body>
</html>